home *** CD-ROM | disk | FTP | other *** search
/ Apple WWDC 1996 / WWDC96_1996 (CD).toast / Technology Materials / QuickTime VR / MacOS / QuickDraw™ 3D 1.0.6F4 SDK / Samples / SampleCode / Tumbler and Podium / Tumbler_traps.c < prev    next >
Encoding:
Text File  |  1995-05-31  |  1013 b   |  52 lines  |  [TEXT/MPS ]

  1. // Simple framework for Macintosh sample code
  2. //
  3. // Nick Thompson, DEVSUPPORT
  4. //
  5. // This file contains the trap detection related code code for the framework.
  6. // 
  7. // 9/16/94    nick    first cut
  8.  
  9. #include <Types.h>
  10. #include <Traps.h>
  11. #include <OSUtils.h>
  12. #include <GestaltEqu.h>
  13.  
  14. #include "Tumbler_Traps.h"
  15.  
  16. #include "Tumbler_traps.h"
  17.  
  18. short myNumToolboxTraps(void);
  19. TrapType myGetTrapType(short theTrap);
  20.     
  21. short myNumToolboxTraps(void)
  22. {
  23.     if (NGetTrapAddress(_InitGraf, ToolTrap) == NGetTrapAddress(0xAA6E,ToolTrap))
  24.         return 0x0200;
  25.     else
  26.         return 0x0400;
  27. }
  28.  
  29. TrapType myGetTrapType(short theTrap)
  30. {
  31.     if ((theTrap & 0x0800) > 0)
  32.         return ToolTrap;
  33.     else
  34.         return OSTrap;
  35. }
  36.  
  37. Boolean    myTrapAvailable(short theTrap)
  38. {
  39.     TrapType tType;
  40.     Boolean isAvail;
  41.     
  42.     tType = myGetTrapType(theTrap);
  43.     if (tType == ToolTrap)
  44.         {
  45.             theTrap &= 0x07FF;
  46.             if (theTrap >= myNumToolboxTraps())
  47.                 theTrap = _Unimplemented;
  48.         }
  49.     
  50.     isAvail = NGetTrapAddress(theTrap, tType) != NGetTrapAddress(_Unimplemented, ToolTrap);
  51.     return isAvail;
  52. }